#include<iostream>
#include<string>
using namespace std;
int main(){
    int n;
    string s;
    cin>>n;
    while (n--)
    {
        cin>>s;
        cout<<"6";
        for(int i=s.size()-5;i<=s.size();i++){
            cout<<s[i];
        }
        cout<<endl;
    }
    
}